package com.tsingteng.cosfun.common;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Build;

import com.tsingteng.cosfun.MainActivity;
import com.tsingteng.cosfun.R;
import com.tsingteng.cosfun.bean.FoundJoinBean;
import com.tsingteng.cosfun.bean.JoinCostarBean;
import com.tsingteng.cosfun.bean.OpusBean;
import com.tsingteng.cosfun.ui.abnormal.AbNormalActivity;
import com.tsingteng.cosfun.ui.cosfun.PlayActivity;
import com.tsingteng.cosfun.ui.costar.CostarActivity;
import com.tsingteng.cosfun.ui.costar.PreViewActivity;
import com.tsingteng.cosfun.ui.costar.VideoDivideActivity;
import com.tsingteng.cosfun.ui.costar.drafts.DraftsAcitvity;
import com.tsingteng.cosfun.ui.costar.publish.VideoPublishActivity;
import com.tsingteng.cosfun.ui.found.ActivityVideoActivity;
import com.tsingteng.cosfun.ui.found.FoundJoinActivity;
import com.tsingteng.cosfun.ui.found.FoundVideoActivity;
import com.tsingteng.cosfun.ui.found.FoundWebViewActivity;
import com.tsingteng.cosfun.ui.found.SunAwardActivity;
import com.tsingteng.cosfun.ui.login.LoginActivity;
import com.tsingteng.cosfun.ui.message.CommonActivity;
import com.tsingteng.cosfun.ui.message.uploadreportfragment.UploadReportActivity;
import com.tsingteng.cosfun.ui.mine.PersonInfoFragment;
import com.tsingteng.cosfun.ui.mine.TerminalActivity;
import com.tsingteng.cosfun.ui.search.SearchActivity;
import com.tsingteng.cosfun.ui.setting.ProfileAdressActivity;
import com.tsingteng.cosfun.ui.setting.ProfileChangeAdressActivity;
import com.tsingteng.cosfun.utils.ImageViewUtils;
import com.tsingteng.cosfun.utils.VideoUtils;

import org.litepal.util.Const;

import java.io.Serializable;
import java.util.List;
import java.util.zip.CheckedOutputStream;

/**
 * 描述: 页面跳转
 * 创建人: 肖利
 * 时间: 2018/8/2
 * qq: (872179966)
 */

public class Navigate {

    /**
     * 跳转本地视屏
     * @param activity
     */
    public static void startLocalVideo(Activity activity) {
        ImageViewUtils.starVideo(activity);
    }
    /**
     * 跳转到预览页面
     * @param context
     * @param path
     */
    public static void startPreVideo(Context context, String path) {
        Intent intent = new Intent(context, PreViewActivity.class);
        intent.putExtra(VideoUtils.VIDEO_PATH,path);
        context.startActivity(intent);
    }
//    /**
//     * 跳转到剪辑页面
//     * @param activity
//     * @param path
//     */
//    public static void startDivideVideo(Activity activity,String path) {
//        Intent intent = new Intent(activity, VideoDivideActivity.class);
//        intent.putExtra("videoPath",path);
//        activity.startActivityForResult(intent,101);
//        activity.finish();
//    }


    /**
     * 跳转到发布页面
     * @param activity
     * @param path
     */
    public static void startPublishVideo(Activity activity,String path) {
        Intent intent = new Intent(activity, VideoPublishActivity.class);
        intent.putExtra("videoPath",path);
        activity.startActivity(intent);
    }


    /**
     * 跳转到相关页面(0 粉丝 ,1 赞我 2,评论我 3 at我 4 ,便当)
     * @param context
     * @param type
     */
    public static  void startCommont(Context context,int type,String funType) {
        Intent intent =  new Intent(context, CommonActivity.class);
        intent.putExtra(CommonActivity.FRAGMENT_KEY,type);
        intent.putExtra("funType",funType);
        context.startActivity(intent);
    }

    /**
     * 跳转用户协议
     * @param context
     * @param type
     * @param agementType
     */
    public static  void startCommont(Context context,int type,int agementType) {
        Intent intent =  new Intent(context, CommonActivity.class);
        intent.putExtra(CommonActivity.FRAGMENT_KEY,type);
        intent.putExtra("agementType",agementType);
        context.startActivity(intent);
    }

    /**
     * @param context
     * @param type
     */
    public static  void startCommont(Context context,int type) {
        Intent intent =  new Intent(context, CommonActivity.class);
        intent.putExtra(CommonActivity.FRAGMENT_KEY,type);
        context.startActivity(intent);
    }


    /**
     * 跳转主页面
     * @param context
     */
    public static void startMain(Context context,boolean isNewTask) {
        Intent intent = new Intent(context, MainActivity.class);
        if (isNewTask) {
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
        }
        context.startActivity(intent);
    }

    /**
     * 跳转d登录界面
     * @param context
     */
    public static void startLogon(Context context,boolean isMain,int type) {
        Intent intent = new Intent(context, LoginActivity.class);
        intent.putExtra("isMain",isMain);
        intent.putExtra("type",type);
        context.startActivity(intent);
        ((Activity)context).overridePendingTransition(R.anim.activity_up,R.anim.activity_up_alpha);
    }

    /**
     * 跳转段子详情界面
     * @param context
     * @param
     * @param profileId
     */
    public static void startPlayDetails(Context context, int id, String name, int profileId, int relationType) {
        Intent intent = new Intent(context, CommonActivity.class);
        intent.putExtra(CommonActivity.FRAGMENT_KEY,CommonActivity.KEY_PLAY_DETAILS);
        intent.putExtra("playId",id);
        intent.putExtra("playName",name);
        intent.putExtra("follow_pid",profileId);
        intent.putExtra("relationType",relationType);
        context.startActivity(intent);
    }

    /**
     * 跳转草稿箱页面
     * @param context
     */
    public static void startDrafts(Context context) {
        Intent intent = new Intent(context, DraftsAcitvity.class);
        context.startActivity(intent);
    }

    /**
     * 跳转到系统通知页面
     * */
    public static void startSystemNotification(Context context){
        Intent intent = new Intent(context, CommonActivity.class);
        intent.putExtra(CommonActivity.FRAGMENT_KEY,CommonActivity.KEY_JUMP_SYSTEM);
        context.startActivity(intent);
    }

    /**
     * 跳转到官方助手通知页面
     * */
    public static void startOfficalNotification(Context context){
        Intent intent = new Intent(context, CommonActivity.class);
        intent.putExtra(CommonActivity.FRAGMENT_KEY,CommonActivity.KEY_JUMP_OFFICAL);
        context.startActivity(intent);
    }

    /**
     * 跳转到私信页面
     * */
    public static void startMessageNotification(Context context, int user_id, String title){
        Intent intent = new Intent(context, CommonActivity.class);
        intent.putExtra(CommonActivity.FRAGMENT_KEY,CommonActivity.KEY_CHAT);
        intent.putExtra("user_id",user_id);
        intent.putExtra("title",title);
        context.startActivity(intent);
    }

    /**
     * 跳转到私信举报页面
     * */
    public static void startChatReport(Context context, String report_id, int tag){
        Intent intent = new Intent(context, CommonActivity.class);
        intent.putExtra(CommonActivity.FRAGMENT_KEY,CommonActivity.KEY_CHATREPORT);
        intent.putExtra("report_id",report_id);
        intent.putExtra("tag",tag);
        context.startActivity(intent);
    }



    /**
     * 跳转到上传举报页面
     * */
    public static void startUploadReport(Context context, int whyReportId,String whyReportMessage, int type, int workId){
        Intent intent = new Intent(context, UploadReportActivity.class);
//        intent.putExtra(CommonActivity.FRAGMENT_KEY,CommonActivity.KEY_FRAGMENTREPORT);
        intent.putExtra("whyReportId",whyReportId);
        intent.putExtra("whyReportMessage",whyReportMessage);
        intent.putExtra("type",type);
        intent.putExtra("workId",workId);
        context.startActivity(intent);
    }

    /**
     * 点击@我，赞我，评论我等页面跳入段子评论列表页
     * */
    public static void startUserComment(Context context,int relatedId){
        Intent intent = new Intent(context, CommonActivity.class);
        intent.putExtra(CommonActivity.FRAGMENT_KEY,CommonActivity.KEY_USERCOMMENT);
        intent.putExtra("id",relatedId);
        context.startActivity(intent);
    }

    /**
     * 点击@我，赞我，评论我等页面跳入段子视频列表页
     * */
    public static void startVideoComment(Context context,int relatedId){
        Intent intent = new Intent(context, CommonActivity.class);
        intent.putExtra(CommonActivity.FRAGMENT_KEY,CommonActivity.KEY_VIDEOCOMMENT);
        intent.putExtra("id",relatedId);
        context.startActivity(intent);
    }

    /**
     * 点击@我，赞我，评论我等页面跳入举报列表页
     * */
    public static void startReportList(Context context, int type, int workId){
        Intent intent = new Intent(context, CommonActivity.class);
        intent.putExtra(CommonActivity.FRAGMENT_KEY,CommonActivity.KEY_REPORTLIST);
        intent.putExtra("type",type);//举报类型
        intent.putExtra("workId",workId);//作品idid
        context.startActivity(intent);
    }

    public static  void startMobile(Context context,String mobile) {
        Intent intent =  new Intent(context, CommonActivity.class);
        intent.putExtra(CommonActivity.FRAGMENT_KEY,CommonActivity.KEY_MOBILE_BIND);
        intent.putExtra("mobile",mobile);
        context.startActivity(intent);
    }
    /**
     * 跳转到异常界面
     */
    public static void gotoAbNormal(Context context,String nickName,String type){
        Intent intent=new Intent(context, AbNormalActivity.class);
        intent.putExtra(Constant.ABNORMAL,nickName);
        intent.putExtra(Constant.MESSAGETYPE,type);
        context.startActivity(intent);
    }
    /**
     * 跳转到收货地址界面
     */
    public static void gotoProfileAdress(Context context){
        Intent intent=new Intent(context, ProfileAdressActivity.class);
        context.startActivity(intent);
    }
    /**
     * 跳转到参加活动界面
     */
    public static void gotoJoin(Activity context, String json, int position) {
        Intent intent = new Intent(context, FoundJoinActivity.class);
        intent.putExtra(Constant.COVERIMGURL, json);
        intent.putExtra(Constant.POSITION,position);
        context.startActivity(intent);
    }
    /**
     * 跳转到活动视频界面
     */
    public static void gotoVideoActivity(Activity context, List<OpusBean> list, int position) {
        Intent intent = new Intent(context, PlayActivity.class);
        intent.putExtra(Constant.COVERIMGURL, (Serializable) list);
        intent.putExtra(Constant.POSITION,position);
        intent.putExtra(Constant.FOUND,"at_video");
        context.startActivity(intent);
    }
    /**
     * 跳转到活动详情界面H5
     *
     */
    public static void gotoActivityDetail(Context context,String url,long id){
        Intent intent = new Intent(context, FoundWebViewActivity.class);
        intent.putExtra(Constant.ACTIVITYID,id);
        intent.putExtra(Constant.URL,url);
        context.startActivity(intent);
    }
    /**
     *
     */
    public static void gotoPlay(Context context,int position,int id,String sortType, int page_no, int page_size){
        Intent intent = new Intent(context, PlayActivity.class);
        intent.putExtra(Constant.POSITION,position);
        intent.putExtra(Constant.ID,id);
        intent.putExtra(Constant.FOUND,"found");
        intent.putExtra(Constant.SORTTYPE,sortType);
        intent.putExtra(Constant.PAGENO,page_no);
        intent.putExtra(Constant.PAGESIZE,page_size);
        context.startActivity(intent);
    }
    public static void gotoJSPlay(Context context,int position,int id,String sortType, int page_no, int page_size,String list){
        Intent intent = new Intent(context, PlayActivity.class);
        intent.putExtra(Constant.POSITION,position);
        intent.putExtra(Constant.ID,id);
        intent.putExtra(Constant.FOUND,"found");
        intent.putExtra(Constant.SORTTYPE,sortType);
        intent.putExtra(Constant.PAGENO,page_no);
        intent.putExtra(Constant.PAGESIZE,page_size);
        intent.putExtra(Constant.DATA,list);
        context.startActivity(intent);
    }

    /**
     * 活动
     * @param context
     * @param ActivityId
     */
    public static void gotoCostar(Activity context,long ActivityId){
        Intent intent=new Intent(context, CostarActivity.class);
        intent.putExtra(Constant.ACTIVITYID,ActivityId);
        context.startActivityForResult(intent,Constant.REQUESTCODE);
        context.overridePendingTransition(R.anim.activity_up, R.anim.activity_down_alpha);
    }
    /**
     * 参与活动发布完成
     */
    public static void gotoJoinDone(Activity context){
        Intent intent=new Intent(context, FoundVideoActivity.class);
        context.startActivity(intent);
//        context.startActivityForResult(intent,Constant.REQUESTCODE);
    }
    /**
     *
     */
    public static void gotoMainActivity(Context context){
        Intent intent = new Intent(context,MainActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        context.startActivity(intent);
    }
    /**
     *
     */
    public static void gotoSunActivity(Context context,long activityId){
        Intent intent=new Intent(context, SunAwardActivity.class);
        intent.putExtra(Constant.ACTIVITYID,activityId);
        context.startActivity(intent);
    }
    /**
     *
     */
    public static void gotoChangeActivity(Context context,String name,String phone,String  regin,String adress){
        Intent intent = new Intent(context, ProfileChangeAdressActivity.class);
        intent.putExtra("name",name);
        intent.putExtra("phone",phone);
        intent.putExtra("region",regin);
        intent.putExtra("adress",adress);
        context.startActivity(intent);
    }
    /**
     * 跳转到search 界面
     */
    public static void gotoSearchActivity(Context context){
//        Intent intent = new Intent(context, SearchActivity.class);
//        context.startActivity(intent);
        TerminalActivity.showFragment(context, SearchActivity.class, null);
    }

}
